<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>学生列表</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.cn/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.cn/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <script src="js/jquery-3.3.1.js"></script>
    <script>
        function showlist(){
            $.get("user/findAll",{},function (data){
                var str="";
                for (let i = 0; i < data.findAllUser.length; i++) {
                    var user = data.findAllUser[i];
                    str+="<tr>" +
                        "<td>"+user.id+"</td>"+
                        "<td>"+user.name+"</td>"+
                        "<td>"+user.sex+"</td>"+
                        "<td>"+user.telephone+"</td>"+
                        "<td>"+user.wechat+"</td>"+
                        "<td>"+user.address+"</td>"+
                        "<td><a type=\"button\" class=\"btn btn-info\" href='add_achievement.html?id="+user.id+"'>添加成绩</a>" +
                        "<a type=\"button\" class=\"btn btn-info\" href='add_student.html?id="+user.id+"'>修改</a>" +
                        "<a type=\"button\" class=\"btn del btn-danger\" href='user/del?id="+user.id+"'>删除</a></td>"+
                        "</tr>";

                }
                $("#stulist").html(str);
            });
        }


        $(function (){
            showlist();
        })
    </script>
</head>
<body>
<div class="col-md-8 col-md-offset-2">
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>名字</th>
            <th>性别</th>
            <th>电话</th>
            <th>微信账号</th>
            <th>地址</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="stulist">

        </tbody>
    </table>
    <a type="button" class="btn btn-success" href="add_student.html">注册学生</a>
</div>
</body>
</html>